<?php
// No direct access to this file
defined('_JEXEC') or die;
 
// import the list field type
jimport('joomla.html.html');
jimport('joomla.form.formfield');
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
 
/**
 * NGMenu Form Field class for the NGMenu component
 */
class JFormFieldMenuName extends JFormFieldList
{
	/**
	 * The field type.
	 *
	 * @var		string
	 */
	protected $type = 'MenuName';
 
//	public function getLabel() {
//	}
 
	public function getInput() {
		require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_menus'.DS.'helpers'.DS.'menus.php' );
		
		$menutypes = MenusHelper::getMenuTypes();
		$menu_type_values = array();
		$db =& JFactory::getDBO();
		foreach($menutypes as $menutype){
			$query = $db->getQuery(true);
			$query->select('title');
			$query->from('#__menu_types');
			$query->where("menutype='".$menutype."'");
			$db->setQuery($query);
			$title = $db->loadResult();
			
			$menu_type_values[] = JHtml::_('select.option', $menutype, $title);
		}

		array_multisort($menu_type_values);

		return JHtml::_('select.genericlist', $menu_type_values, $this->name, null, 'value', 'text', $this->value);
	}
}
